//
//  GTGiftCommentCell.m
//  GiftTalk
//
//  Created by Wan on 16/4/2.
//  Copyright © 2016年 Wan. All rights reserved.
//

#import "GTGiftCommentCell.h"
#import "UIImageView+Extension.h"
#import "GTGiftComment.h"

@interface GTGiftCommentCell ()

@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *commentLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;


@end

@implementation GTGiftCommentCell

- (void)awakeFromNib {
    // Initialization code
    
    // 设置头像圆角
    self.iconView.layer.cornerRadius = self.iconView.width * 0.5;
    self.iconView.clipsToBounds = YES;
}


+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    GTGiftCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"commentCell"];
    if (cell == nil) {
        cell = [self viewFromXib];
    }
    return cell;
}

- (void)setComment:(GTGiftComment *)comment
{
    _comment = comment;
    
    [self.iconView setImage:comment.avatar_url placeHolder:@"defaultUserIcon"];
    
    self.nameLabel.text = comment.nickname;
    self.commentLabel.text = comment.content;
    self.timeLabel.text = comment.created_at;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
